using System;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.ComponentModel;
using Northwind.NET.Security;


namespace Northwind.NET.Model
{
	[DataContract]
	//[CollectionDataContract]
	public class OrderCollection : SecureCollection<Order>
	{

	}

	/// <summary>
	/// only serves as an example class to run tests for the ConvertExtension class
	/// </summary>
	//public class ComplexType
	//{
	//    public Product Product { get; set; }
	//    public Customer Customer { get; set; }
	//    public Category Category { get; set; }
	//    public Supplier Supplier { get; set; }
	//}

	public abstract class SequencedObject: INotifyPropertyChanged
	{
		public abstract ISequencedObjectKey Key { get; set; }
		public abstract Nullable<System.Int32> ID { get; set; }
		public abstract string Name { get; set; }
		public abstract SecureString SecureName { get; set; }
		public abstract Nullable<PermissionTypeEnum> PermissionType { get; set; }
		#region INotifyPropertyChanged Members
		public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
		protected virtual void OnPropertyChanged(string propertyName)
		{
			System.ComponentModel.PropertyChangedEventHandler handler = this.PropertyChanged;
			if (handler == null) return;
			var args = new System.ComponentModel.PropertyChangedEventArgs(propertyName);
			handler(this, args);
		}
		protected string GetMemberName<T>(System.Linq.Expressions.Expression<Func<T>> expr)
		{
			System.Linq.Expressions.MemberExpression mem = (System.Linq.Expressions.MemberExpression)expr.Body;
			return mem.Member.Name;
		}
		#endregion
	}

	public class CustomerKey : ISequencedObjectKey
	{
		public long? Sequence { get; set; }
		public int? ID { get; set; }
	}
	public class ProductKey : ISequencedObjectKey
	{
		public long? Sequence { get; set; }
		public int? ID { get; set; }
	}
	public interface ISequencedObjectKey
	{
		long? Sequence { get; set; }
		int? ID { get; set; }
	}
}


namespace Northwind.NET.Model
{
	public class Product : SequencedObject
	{
		public override ISequencedObjectKey Key { get; set; }
		public override Nullable<System.Int32> ID { get; set; }
		public override PermissionTypeEnum? PermissionType { get; set; }
		public override SecureString SecureName { get; set; }
		string _Name;
		public override string Name
		{
			get { return _Name; }
			set 
			{ 
				_Name = value;
				OnPropertyChanged("Name");
			}
		}

		SecurityHandle _SecurityHandle;
		public SecurityHandle SecurityHandle
		{
			get { return _SecurityHandle; }
			set
			{
				if (_SecurityHandle == value) { return; }
				_SecurityHandle = value;
				OnPropertyChanged("SecurityHandle");
			}
		}
        
		public System.Nullable<System.Int32> SupplierID { get; set; }
		public System.Nullable<System.Int32> CategoryID { get; set; }
		public System.String QuantityPerUnit { get; set; }
		public System.Nullable<System.Decimal> UnitPrice { get; set; }
		public System.Nullable<System.Int16> UnitsInStock { get; set; }
		public System.Nullable<System.Int16> UnitsOnOrder { get; set; }
		public System.Nullable<System.Int16> ReorderLevel { get; set; }
		public System.Nullable<System.Boolean> Discontinued { get; set; }
		public System.Collections.Generic.List<System.Byte> RowTimeStamps { get; set; }

		//can handle circular references, but it eats up memory!
		//public Northwind.NET.Model.Category Category { get; set; } 
		//public System.Collections.Generic.List<Northwind.NET.Model.OrderDetail> OrderDetails { get; set; }
		public Northwind.NET.Model.Supplier Supplier { get; set; }

	}
}

namespace Northwind.NET.Model
{
	public class Customer : SequencedObject
	{
		public override ISequencedObjectKey Key { get; set; }
		public override Nullable<System.Int32> ID { get; set; }
		public System.String Code { get; set; }
		public override System.String Name { get; set; }
		public override SecureString SecureName { get; set; }
		public override PermissionTypeEnum? PermissionType { get; set; }

		SecurityHandle _SecurityHandle;
		public SecurityHandle SecurityHandle
		{
			get { return _SecurityHandle; }
			set
			{
				if (_SecurityHandle == value) { return; }
				_SecurityHandle = value;
				OnPropertyChanged("SecurityHandle");
			}
		}
        
		public System.String ContactName { get; set; }
		public System.String ContactTitle { get; set; }
		public System.String Address { get; set; }
		public System.String City { get; set; }
		public System.String Region { get; set; }
		public System.String PostalCode { get; set; }
		public System.String Country { get; set; }
		public System.String Phone { get; set; }
		public System.String Fax { get; set; }
		public System.Collections.Generic.List<System.Byte> RowTimeStamps { get; set; }
		public OrderCollection Orders { get; set; }

	}
}
namespace Northwind.NET.Model
{
	public class Shipper : SequencedObject
	{
		public override ISequencedObjectKey Key { get; set; }
		public override Nullable<System.Int32> ID { get; set; }
		public override System.String Name { get; set; }
		public override SecureString SecureName { get; set; }		
		public override PermissionTypeEnum? PermissionType { get; set; }
		public System.String Phone { get; set; }
		public System.Collections.Generic.List<System.Byte> RowTimeStamps { get; set; }
		public OrderCollection Orders { get; set; }

	}
}


namespace Northwind.NET.Model
{
	public class Supplier : SequencedObject
	{
		public override ISequencedObjectKey Key { get; set; }
		public override Nullable<System.Int32> ID { get; set; }
		public override System.String Name { get; set; }
		public override SecureString SecureName { get; set; }
		public override PermissionTypeEnum? PermissionType { get; set; }
		public System.String ContactName { get; set; }
		public System.String ContactTitle { get; set; }
		public System.String Address { get; set; }
		public System.String City { get; set; }
		public System.String Region { get; set; }
		public System.String PostalCode { get; set; }
		public System.String Country { get; set; }
		public System.String Phone { get; set; }
		public System.String Fax { get; set; }
		public System.String HomePage { get; set; }
		public System.Collections.Generic.List<System.Byte> RowTimeStamps { get; set; }
		public System.Collections.Generic.List<Northwind.NET.Model.Product> Products { get; set; }

	}
}

namespace Northwind.NET.Model
{
	public class Category
	{
		public Nullable<System.Int32> ID { get; set; }
		public System.String Name { get; set; }
		public System.String Description { get; set; }
		public System.Collections.Generic.List<System.Byte> Pictures { get; set; }
		public System.Collections.Generic.List<System.Byte> RowTimeStamps { get; set; }
		public System.Collections.Generic.List<Northwind.NET.Model.Product> Products { get; set; }
	}
}


namespace Northwind.NET.Model
{
	public class Employee
	{
		public System.Int32 ID { get; set; }
		public System.String LastName { get; set; }
		public System.String FirstName { get; set; }
		public System.String Title { get; set; }
		public System.String TitleOfCourtesy { get; set; }
		public System.Nullable<System.DateTime> BirthDate { get; set; }
		public System.Nullable<System.DateTime> HireDate { get; set; }
		public System.String Address { get; set; }
		public System.String City { get; set; }
		public System.String Region { get; set; }
		public System.String PostalCode { get; set; }
		public System.String Country { get; set; }
		public System.String HomePhone { get; set; }
		public System.String Extension { get; set; }
		public System.String Photo { get; set; }
		public System.String Notes { get; set; }
		public System.Nullable<System.Int32> ReportsTo { get; set; }
		public System.Collections.Generic.List<System.Byte> RowTimeStamps { get; set; }
		public OrderCollection Orders { get; set; }

	}
}

namespace Northwind.NET.Model
{
	public class Order
	{
		public System.Int32 ID { get; set; }
		public System.Nullable<System.Int32> CustomerId { get; set; }
		public System.Nullable<System.Int32> EmployeeID { get; set; }
		public System.Nullable<System.DateTime> OrderDate { get; set; }
		public System.Nullable<System.DateTime> RequiredDate { get; set; }
		public System.Nullable<System.DateTime> ShippedDate { get; set; }
		public System.Nullable<System.Int32> ShipperId { get; set; }
		public System.Nullable<System.Decimal> Freight { get; set; }
		public System.String ShipName { get; set; }
		public System.String ShipAddress { get; set; }
		public System.String ShipCity { get; set; }
		public System.String ShipRegion { get; set; }
		public System.String ShipPostalCode { get; set; }
		public System.String ShipCountry { get; set; }
		public System.Collections.Generic.List<System.Byte> RowTimeStamp { get; set; }
		public Northwind.NET.Model.Customer Customer { get; set; }
		public Northwind.NET.Model.Employee Employee { get; set; }
		//public System.Collections.Generic.List<Northwind.NET.Model.OrderDetail> OrderDetails { get; set; }
		public Northwind.NET.Model.Shipper Shipper { get; set; }

	}
}

//namespace Northwind.NET.Model
//{
//    public class OrderDetail
//    {
//        public System.Int32 ID { get; set; }
//        public System.Nullable<System.Int32> OrderID { get; set; }
//        public System.Nullable<System.Int32> ProductID { get; set; }
//        public System.Nullable<System.Decimal> UnitPrice { get; set; }
//        public System.Nullable<System.Int16> Quantity { get; set; }
//        public System.Nullable<System.Single> Discount { get; set; }
//        public System.Collections.Generic.List<System.Byte> RowTimeStamps { get; set; }
//        public Northwind.NET.Model.Order Order { get; set; }
//        public Northwind.NET.Model.Product Product { get; set; }

//    }
//}



